package com.sanpu.kxe.business.trade.view;

import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseTitleActivity;
import com.sanpu.kxe.business.trade.contract.TradeConfig;
import com.sanpu.kxe.module.roundview.RoundTextView;
import com.sanpu.kxe.module.specialunit.SimplifySpanBuild;
import com.sanpu.kxe.module.specialunit.unit.SpecialTextUnit;

import butterknife.Bind;

/**
 * Description：提现结果页
 * Created by 薛勇军 on 2018/8/9.
 */

public class WithdrawDetailsActivity extends BaseTitleActivity {

    @Bind(R.id.des)
    TextView vDes;
    @Bind(R.id.amount)
    TextView vAmount;
    @Bind(R.id.succeed)
    ImageView vSucceed;
    @Bind(R.id.fail)
    ImageView vFail;
    @Bind(R.id.next)
    RoundTextView vNext;
    @Bind(R.id.state)
    TextView vState;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_withdraw_details;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("提现详情");

        String amt = getIntent().getStringExtra(TradeConfig.INTENT_AMOUNT);
        String des = getIntent().getStringExtra(TradeConfig.INTENT_REMARK);
        boolean result = getIntent().getBooleanExtra(TradeConfig.INTENT_ISOK, false);
        SimplifySpanBuild build = new SimplifySpanBuild(this, vAmount, "本次提现金额：");
        build.appendSpecialUnit(new SpecialTextUnit(amt, ContextCompat.getColor(mContext, R.color.color_base)));
        build.appendSpecialUnit(new SpecialTextUnit("元"));
        vAmount.setText(build.build());

        vState.setText(result ? "你的提现申请成功" : "你的提现申请未成功！");

        if (!result && !TextUtils.isEmpty(des)) {
            SimplifySpanBuild desBuild = new SimplifySpanBuild(this, vAmount, "失败原因：");
            desBuild.appendSpecialUnit(new SpecialTextUnit(des, ContextCompat.getColor(mContext, R.color.color_base)));
            vDes.setText(desBuild.build());
        } else {
            vDes.setVisibility(View.GONE);
        }

        if (result) {
            vFail.setVisibility(View.GONE);
        } else {
            vSucceed.setVisibility(View.GONE);
        }
    }

    @Override
    protected void setListener() {
        super.setListener();
        vNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }
}
